<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en" >
<head>
    <meta charset="text/html;UTF-8">
    <title>thymeleaf Title</title>
</head>
<body>

<div>

    <form enctype="multipart/form-data" id="uploadForm">
        <input type="file" name="uploadFile" id="upload_file" style="margin-bottom:10px;"/>
        <input type="button" id="uploadPicButton" value="上传" onclick="uploadImage()"/>
    </form>

</div>

</body>

<script src="../jquery-3.3.1.min.js"></script>

<script>

    function uploadImage() {
        var uploadUrl = "http://localhost:9090/tshirt/upload/uploadImage";
        var pic = $('#upload_file')[0].files[0];
        var fd = new FormData();
        //fd.append('uploadFile', pic);
        fd.append('file', pic);
        $.ajax({
            url: uploadUrl,
            type: "post",
            // Form数据
            data: fd,
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {
                console.log("the data is : {}", data);
                if (data.code == 0) {

                }
            }
        });
    }

</script>
</html>